﻿using DryWCS.Model.Flatcar;
using DryWCS.Service.DbContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DryWCS.Service.Flatcar
{
    public class FlatcarTaskHisService : LocalDbContext<FlatcarTaskHisEntity>
    {
        public List<FlatcarTaskHisEntity> GetListByTime(DateTime startTime, DateTime endTime)
        {
            try
            {
                return Db.Queryable<FlatcarTaskHisEntity>().Where(p => p.EndTime >= startTime && p.EndTime <= endTime).OrderBy(p => p.Id).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public List<FlatcarTaskHisEntity> GetListByLike(string search)
        {
            try
            {
                return Db.Queryable<FlatcarTaskHisEntity>()
                    .Where(p => /*p.Id.ToString().Contains(search)*/
                     p.WMSOrderId.ToString().Contains(search)
                    || p.TaskType.ToString().Contains(search)
                    || p.Status.ToString().Contains(search)
                    /*|| p.CreateTime.ToString().Contains(search)
                    || p.StartTime.ToString().Contains(search)
                    || p.EndTime.ToString().Contains(search)*/).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
